<?php
namespace App\Libraries\Log;

use App\Common\Config;
use Illuminate\Contracts\Logging\Log;
use Monolog\Formatter\LineFormatter;
use Monolog\Handler\RotatingFileHandler;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;

/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2015/12/19
 * Time: 17:41
 */
class OrderLog{

    private static $logger ;

    private static function getLogger(){
        if (empty(self::$logger)) {
            self::$logger = new Logger('orderLog',[(new RotatingFileHandler(storage_path('logs/order.log'), 1, Logger::INFO))
                ->setFormatter(new LineFormatter(null, null, true, true))]);
        }
        return self::$logger;
    }

    public static function info($order){
        if(empty($order)){
            return ;
        }
        $info = 'order_id:'.$order['order_id'].' status:'.$order['status'].' member_id:'.$order['member_id'].' role:'.$order['role'].' message:'.$order['message'];
        OrderLog::getLogger()->info($info);
    }

    public static function error($msg=''){
        if(empty($msg)){
            return ;
        }
        OrderLog::getLogger()->error($msg);
    }
}